/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-09-22
 * Time: 16:05
 */
public class is_Unique {

    public boolean isUnique(String astr) {
        if (astr.length() > 26) return false;
        int bitMap = 0;
        for (int i = 0; i < astr.length(); i++) {
            int x = astr.charAt(i) - 'a';
            // 先判断字符是否在位图中
            if (((bitMap >> x) & 1) == 1) return false;
            // 把当前字符加⼊到位图中
            bitMap |= (1 << x);
        }
        return true;
    }

    public static void main(String[] args) {
    }
}
